

class EventStore {
   eventList= []; // { event: 'xx', callbackList: [] }
    on=(event, callback)=> {
      const target = this.eventList.find(item => item.event === event);
      if(target){
        target.callbackList.push(callback)
      }else{
        this.eventList.push({
          event, 
          callbackList: [callback]
        })
      }
    }
    emit=(event, ...args)=>{
      const target = this.eventList.find(item => item.event === event);
      if(target){
        target.callbackList.forEach(callback=>{
          callback(...args)
        })
      }
    }
}


export default new EventStore();